package cn.iocoder.yudao.module.product.enums.spu;

import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 商品类型
 *
 * @author lizhognwen
 */
@Getter
@AllArgsConstructor
public enum ProductTypeEnum implements IntArrayValuable {
    GENERAL(0, "通用"),
    GIFT_CARD(1, "礼品卡"),
    ESIM_CARD(2, "eSim卡"),
    ESIM_DATA_PACKAGE(3, "eSim数据包");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductTypeEnum::getValue).toArray();

    /**
     * 状态
     */
    private final Integer value;

    /**
     * 状态名
     */
    private final String desc;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static ProductTypeEnum fromValue(int value) {
        for (ProductTypeEnum type : values()) {
            if (type.value == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("枚举类型 ProductTypeEnum 不支持整型值：" + value);
    }

}
